package tool

import (
	"flag"
	"fmt"
)

type Cmd struct {
	Help    bool
	Version bool
	CP      string
	Xjre    string
	Class   string
	Args    []string
}

type Path struct {
	BootClasspath   string
	ExtendClasspath string
	UserClasspath   []string
}

var args *Cmd

func GetArgs() Cmd {
	return *args
}

// true, ok
func ParseArgs() bool {
	var cmd = &Cmd{}
	flag.BoolVar(&cmd.Help, "help", false, "help")
	flag.BoolVar(&cmd.Help, "?", false, "help")
	flag.BoolVar(&cmd.Version, "version", false, "version")
	flag.StringVar(&cmd.CP, "cp", "", "cp - class path")
	flag.StringVar(&cmd.Xjre, "Xjre", "", "java jre path")

	flag.Parse()

	if len(flag.Args()) > 0 {
		cmd.Class = flag.Arg(0)
		cmd.Args = flag.Args()[1:]
	}
	args = cmd

	if cmd.Help {
		fmt.Println(`
	jvm-GO 0.0.1
		-help 
		-?
		-version
		-cp 		classpath
		-Xjre 		jre path
		`)
		return false
	}

	if cmd.Version {
		fmt.Println("jvm-GO 0.0.1")
		return false
	}

	return true
}
